#-*- encoding: gb2312 -*-  

import pamie as p
import time
import sys  
reload(sys)   
sys.setdefaultencoding('gb2312')

f = open('tmp.txt','w')
def getSubLinks(ln):
	
	tmp = p.PAMIE(ln)
	tmp.navigate(ln)
	slns = tmp.getLinks()
	
	for m in range(1,len(slns)):
		if slns[m].getAttribute('href').find('.rar') > 0 :
			try:
				#f.write(slns[m].getAttribute('href'))
				#f.write('\n')
				ln = slns[m].getAttribute('href')
				print  ln
			except pywintypes.com_error:
				print "get some error"
				continue
	tmp.quit()
	
	
ie = p.PAMIE('http://10.1.64.21/SoftPlat/SoftPlat_Query/Query_UnCloseChange.aspx')
lns = ie.getLinks()

for n in range(1,len(lns) - 2):
	ln = lns[n].getAttribute('href')
	if len(ln) == 70:
		print n
		getSubLinks(ln)
		break
ie.quit()
f.close()